package com.sun.talk.mapper

import com.baomidou.mybatisplus.core.mapper.BaseMapper
import com.sun.talk.entity.User
import com.sun.talk.entity.vo.FriendsRequestVO
import com.sun.talk.entity.vo.MyFriendVO
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.annotations.Update

interface UserMapper : BaseMapper<User> {
    @Select("SELECT sender.id as sendUserId,sender.username as sendUsername,sender.nickname as sendNickname,sender.face_image as sendFaceImage FROM friends_request fr LEFT JOIN user sender ON fr.send_user_id = sender.id WHERE fr.accept_user_id = #{acceptUserId}")
    fun queryFriendRequestList(acceptUserId:String):List<FriendsRequestVO>

    @Select("SELECT u.id as friendUserId,u.username as friendUsername,u.nickname as friendNickname,u.face_image as friendFaceImage FROM my_friends mf LEFT JOIN user u ON u.id = mf.my_friend_user_id WHERE mf.my_user_id = #{userId} ")
    fun queryFriendList(userId:String):List<MyFriendVO>

    @Update("UPDATE chat_msg SET sign_flag = 1 WHERE id in (#{msgIds})")
    fun batchUpdateMsgSigned(msgIds:String)
}